<%-- 
    Document   : addrecvicelist
    Created on : 2016-9-5, 21:09:28
    Author     : 52461
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include  file="../link.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <link href="${base}/css/bootstrap.css" rel="stylesheet">
        <link href="${base}/css/font-awesome.css" rel="stylesheet">
        <link href="${base}/css/material-kit.css" rel="stylesheet">
        <link href="${base}/css/bootstrap-material-datetimepicker.css" rel="stylesheet">
        <link href="${base}/css/nprogress.css" rel="stylesheet">

        <script type="text/javascript" src="${base}/js/jquery-1.9.1.js"></script>
        <script type="text/javascript" src="${base}/js/nprogress.js"></script>
        <script type="text/javascript" src="${base}/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="${base}/js/material.min.js"></script>
        <script type="text/javascript" src="${base}/js/mi.js"></script>
        <script type="text/javascript" src="${base}/js/material-kit.js"></script>
        <script type="text/javascript" src="${base}/js/moment-with-locales.min.js"></script>
        <script type="text/javascript" src="${base}/js/bootstrap-material-datetimepicker.js"></script>


        <script type="text/javascript" src="${base}/js/angular/angular.min.js"></script>
        <script type="text/javascript" src="${base}/js/angular/ui-bootstrap-tpls-0.12.0.min.js"></script>
        <script type="text/javascript" src="${base}/js/jquery.cxhd.js"></script>
        <script type="text/javascript" src="${base}/js/angular-base.js"></script>
        <title>JSP Page</title>
    </head>

    <body ng-app="recvice" style="font-family: 微软雅黑;padding-top: 10px;background-color: #ffffff" ng-controller="mainCtrl">

        <div class="col-lg-12">
            <div class="panel panel-default ">
                <div class=" panel-heading">
                    <strong><span class="glyphicon glyphicon-th"></span>医生工作站</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <button title="刷新"  ng-click="getRecviceList()" style="margin: 0px;" class="btn btn-default btn-round btn-xs">
                        <i class="fa fa-refresh"></i>&nbsp;&nbsp;刷新
                    </button>

                    <button title="等待接诊"  ng-click="getRecviceList('0')" style="margin: 0px;" class="btn btn-default btn-round btn-xs">
                        <i class="fa fa-star"></i>&nbsp;&nbsp;等待接诊
                    </button>

                    <button title="接诊中"  ng-click="getRecviceList('1')" style="margin: 0px;" class="btn btn-default btn-round btn-xs">
                        <i class="fa fa-star"></i>&nbsp;&nbsp;接诊中
                    </button>

                    <button title="已完成"  ng-click="getRecviceList('2')" style="margin: 0px;" class="btn btn-default btn-round btn-xs">
                        <i class="fa fa-star"></i>&nbsp;&nbsp;已完成
                    </button>
                </div>
                <table class="table">
                    <tr>
                        <th style="">序号</th>
                        <th>病人姓名</th>
                        <th>性别</th>
                        <th>年龄</th>
                        <th>电话</th>
                        <th>就诊医生</th>
                        <th>预约时间</th>
                        <th>联系人</th>
                        <th>联系电话</th>
                        <th>状态</th>
                        <th>备注</th>
                        <th>其他</th>
                    </tr>
                    <tr  ng-repeat="item in recvicelist">
                        <td ng-bind="$index"></td>
                        <td ng-bind="item.patient_name"></td>
                        <td ng-bind="item.sex"></td>
                        <td ng-bind="item.age"></td>
                        <td ng-bind="item.phone"></td>                              
                        <td ng-bind="item.recvicer_name"></td>
                        <td  ng-bind="item.appointment_time"></td>
                        <td  ng-bind="item.contact"></td>
                        <td  ng-bind="item.contact_phone"></td>
                        <td  ng-bind="item.status_name"></td>
                        <td style="width: 100px;overflow-x: hidden" title="{{item.description}}"  ng-bind="item.description"></td>
                        <td ng-hide="!recvicelist">
                    <buton title="查看申请单" class="btn btn-primary btn-xs" ng-click="viewDetail(item)">查看</buton>       
                    <buton class="btn btn-primary btn-xs" ng-click="openRpt(item)">报告</buton>
                    <buton class="btn btn-info btn-xs" ng-click="openDetail(item)">资料</buton>
                    <buton class="btn btn-success btn-xs" ng-click="openVideo(item)"><i class="fa fa-video-camera"></i></buton>

                    </td>
                    </tr>
                </table>
                <div class="panel-heading" style="margin: 0px;padding: 0px;padding-top: 5px;">
                    <div  style="text-align: center">                
                        <pagination ng-change="recvicePageChanged()" previous-text="上一页" next-text="下一页" first-text="第一页" last-text="最后一页" ng-model="recvice.currentPage" items-per-page="recvice.pageSize" total-items="recvice.bigTotalItems" ng-model="recvice.bigCurrentPage" max-size="recvice.maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages"></pagination>

                    </div>           
                </div>
            </div>

        </div>


    </body>
</html>
<script>

    angular.module("recvice", ['baseModule', 'ui.bootstrap'])
            .controller("mainCtrl", function ($scope, base) {

                $scope.data = {};

//                *******************************************
                var so = $scope;
                $scope.recvice = {currentPage: 1};
                so.setRecvicePage = function (pageNo) {
                    $scope.recvice.currentPage = pageNo;
                };
                so.recvicePageChanged = function () {
                    so.getAskList();
                };
                so.recvice.maxSize = 10;
                so.recvice.bigTotalItems = 20;
                so.recvice.bigCurrentPage = 1;
                so.recvice.pageSize = 10;



                $scope.saveInfo = function () {
                    base.post("add/saveAsk", $scope.data).get(function (data) {
                        if (data == "true") {
                            steveAl("保存成功", 1000);
                            $(".mode-x").modal('hide');
                            $scope.data = {};
                            $scope.getAskList();
                        } else {
                            steveAl("保存失败", 1000);
                        }
                    });
                }
                $scope.getRecviceList = function (st) {
                    var status = "";
                    if (st) {
                        status = st;
                    }
                    base.post("recvice/getRecviceList", {status: status, pageSize: so.recvice.pageSize, currentPage: so.recvice.currentPage}).get(function (data) {
                        if (data) {
                            so.recvicelist = data.list;
                            so.recvice.bigTotalItems = data.totalRow;

                            for (var i in so.recvicelist) {
                                // console.log(so.asklist[i].status==0);
                                if (so.recvicelist[i].status == 0) {
                                    so.recvicelist[i].status_name = "等待接诊";
                                } else if (so.recvicelist[i].status == 1) {
                                    so.recvicelist[i].status_name = "接诊中..";
                                } else if (so.recvicelist[i].status == 2) {
                                    so.recvicelist[i].status_name = "已完成";
                                }

                            }
                        }
                    })
                }

                $scope.openDetail = function (item) {
                    base.post("recvice/changeStatus", {order_id: item.pk}).get(function (data) {
                        if (window.parent) {

                            window.parent.addNewTab({href: "patient/patient_detail?host_id="+ item.patient_id + "&patientName=" + item.patient_name,
//                            icon: icon,
                                        title: "" + item.patient_name + "的资料"})

                            //window.parent.openPatInfo("patient/patient_detail?host_id=" + item.patient_id + "&patientName=" + item.patient_name);
                        }
                        $scope.getRecviceList();
                    })

                }
                 $scope.viewDetail = function (item) {

                    if (window.parent) {
                        window.parent.addNewTab({href: window.location.pathname + "/viewApply?ask_code=" + item.ask_code+"&type=manager",
//                            icon: icon,
                            title: item.patient_name + "的申请单"})
                    } else {
                        window.open("add/viewApply?ask_code=" + item.ask_code);
                    }
                }
                $scope.openRpt = function (item) {
                    if (window.parent) {

                        window.parent.addNewTab({href: "patient/openRpt?host_id=" + item.patient_id + "&order_id=" + item.pk,
//                            icon: icon,
                            title: item.patient_name + "会诊报告单"})
                    }else{
                    window.open("${base}/patient/openRpt?host_id=" + item.patient_id + "&order_id=" + item.pk);
                }
                }
                $scope.openVideo = function (item) {
//                     if (window.parent) {
//                            window.parent.addNewTab({href: config.videoUrl + item.pk,
////                            icon: icon,
//                                title: "与"+item.hospital_name+"视频中"})
//                        } else {
                           window.open(config.videoUrl + item.pk);
                       // }
                    //window.open(config.videoUrl + item.pk);

                }



                var init = function () {
                    $scope.getRecviceList();

                }
                init();

            })
</script>
